<template>
  <div class="screen_section">
    <div class="screen_container" ref="screen">
      <div class="container_top">
        <Top />
      </div>
      <div class="container_bottom">
        <div class="bottom_left">
          <Tourist class="tourist"></Tourist>
          <Sex class="sex"></Sex>
          <Age class="age"></Age>
        </div>
        <div class="bottom_center">
          <Map class="map"></Map>
          <Line class="line"></Line>
        </div>
        <div class="bottom_right">
          <Rank class="rank"></Rank>
          <Year class="year"></Year>
          <Counter class="count"></Counter>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
//获取数据大屏展示内容盒子的DOM元素
import Top from './components/top/index.vue'
import Tourist from './components/tourist/index.vue'
import Sex from './components/sex/index.vue'
import Age from './components/age/index.vue'

//引入中间两个子组件
import Map from './components/map/index.vue'
import Line from './components/line/index.vue'

import Rank from './components/rank/index.vue'
import Year from './components/year/index.vue'
import Counter from './components/couter/index.vue'
let screen = ref()
onMounted(() => {
  INIT_SCALE()
})
//定义大屏缩放比例
function getScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w
  const wh = window.innerHeight / h
  return ww < wh ? ww : wh
}
//监听视口变化
window.onresize = () => {
  INIT_SCALE()
}

const INIT_SCALE = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}
</script>

<style scoped lang="scss">
.screen_section {
  width: 100vw;
  height: 100vh;
  background: url('./images/bg.png') no-repeat;
  background-size: cover;
  .screen_container {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 1920px;
    height: 1080px;
    transform-origin: left top;
    .container_top {
      width: 100%;
      height: 40px;
    }

    .container_bottom {
      display: flex;
      padding-bottom: 20px;
      .bottom_right {
        flex: 1;
        display: flex;
        flex-direction: column;
        // margin-left: 40px;

        .rank {
          flex: 1.5;
        }

        .year {
          flex: 1;
        }

        .count {
          flex: 1;
        }
      }

      .bottom_left {
        flex: 1;
        display: flex;
        flex-direction: column;

        .tourist {
          flex: 1.2;
        }

        .sex {
          flex: 1;
        }

        .age {
          flex: 1;
        }
      }

      .bottom_center {
        flex: 2;
        display: flex;
        flex-direction: column;
        // padding: 0 20px;
        .map {
          flex: 4;
        }

        .line {
          flex: 1;
        }
      }
    }
  }
}
</style>
